package prepro;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class AddSentenceEnumaration {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new FileReader(new File(
				"/local/joofeit/dewacCleanInts")));
		BufferedWriter bw = new BufferedWriter(new FileWriter(new File(
				"/local/joofeit/dewacCleanNew")));
		String line = "";
		int counter = 0;
		StringBuffer sb = new StringBuffer();
		int sentLength = 0;
		boolean betweenSentence = false;
		while ((line = br.readLine()) != null) {
			if (counter == 0 && line.isEmpty()) {
				bw.write("<" + counter + ">" + "\n");
				counter++;
			}
			if (line.isEmpty() && !betweenSentence) {
				betweenSentence = true;
				// bw.write(line);
			} else if (line.isEmpty() && betweenSentence) {
				if (sentLength > 3) {
					bw.write(sb.toString());
					bw.write("<" + counter + ">" + "\n");
					counter++;

				}
				sb = new StringBuffer();
				sentLength = 0;

				betweenSentence = false;
			} else if (line.split(" ").length == 4) {
				sb.append(line + "\n");
				sentLength++;
				// bw.write(line+"\n");
			} else {
				throw new Error("ERROR");
			}
		}
		bw.close();
		br.close();
	}
}
